package io.jt808.proto.cmd;

import io.norland.buffer.AutoBuffer;
import io.norland.annotations.Proto;
import io.norland.proto.IProto;
import lombok.Data;

/**
 * 数据下行透传
 */
@Proto("8900")
@Data
public class JT8900 implements IProto {
    /**
     * 透传消息类型
     */
    private byte messageType;
    /**
     * 透传消息内容
     */
    private byte[] messageContent;

    public final byte[] writeToBytes() {
        AutoBuffer buffer = new AutoBuffer();
        buffer.writeByte(messageType);
        buffer.writeBytes(messageContent);
        return buffer.array();
    }

    public final void readFromBuf(AutoBuffer buffer) {
        messageType = buffer.readByte();
        messageContent = buffer.readBytes();
    }
}